package com.test.practice.word;

import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.data.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.*;
import java.util.HashMap;

/**
 * @Description: =======================
 * @Author: Jovi
 * =======================
 * @Date: Created in 2023-02-10
 * =======================
 * @Version: 1.1.2.0
 */
public class Demo {

    public static void main(String[] args) throws IOException {

        String content = "<p>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;</p><p><br></p><p>&lt;project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"</p><p> &nbsp; &nbsp; &nbsp; &nbsp; xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"&gt;</p><p> &nbsp; &nbsp;&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</p><p>#{company_stamp:律所盖章}</p><p><span style=\"font-size: 16px;\">阿斯顿发斯蒂芬#{company_stamp:公司盖章}#{company_stamp:律所盖章}|args:被申请人手机号||args:申请人邮箱|</span></p><p><strong>|args:申请人姓名|；</strong><u><em><strong>解决； </strong></em></u></p><p><u><em><strong>手动阀</strong></em></u></p><p> </p>";

        FileOutputStream fos = new FileOutputStream("123.docx");



        byte[] b = content.getBytes("GBK"); //这里是必须要设置编码的，不然导出中文就会乱码。
        ByteArrayInputStream bais = new ByteArrayInputStream(b);//将字节数组包装到流中
        try {

            POIFSFileSystem poifs = new POIFSFileSystem();
            DirectoryEntry directory = poifs.getRoot();
            DocumentEntry documentEntry = directory.createDocument("WordDocument", bais);
            poifs.writeFilesystem(fos);
            bais.close();
            fos.close();
        }catch(Exception e){
            e.printStackTrace();
        }finally {
            if(bais!=null){bais.close();}
            if(fos!=null) {fos.flush();fos.close();}
        }

    }

    public static void exportWord() throws Exception {



    }


}
